package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.vo.BookVO;
import com.briup.estore.service.BookService;
import com.briup.estore.service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author briup-adam
 * @Date 2023/8/3 下午3:17
 * @Description 通过分类id查找书籍信息
 **/

@WebServlet("/book/category")
public class BookCategoryServlet extends  BaseServlet {
    private BookService bookService=new BookServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer id = Integer.valueOf(req.getParameter("id"));
        List<BookVO> list = bookService.getBooksByCategoryId(id);
        writeData(resp,Result.success(list));
    }
}
